package controller;

import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.Sessions;
import org.zkoss.zk.ui.select.SelectorComposer;
import org.zkoss.zk.ui.select.annotation.Listen;
import org.zkoss.zk.ui.select.annotation.Wire;
import org.zkoss.zul.Label;
import org.zkoss.zul.Window;

public class ModalDialogController extends SelectorComposer<Component> {
	private static final long serialVersionUID = 1L;
	@Wire
	private Label dangNhap, dangKy;

	@Listen("onClick=#dangKy")
	public void showFormRegister() {
		if (dangKy.getValue().equals("ĐĂNG KÝ")) {
			Window window = (Window) Executions.createComponents(
					"form_register.zul", null, null);
			window.doModal();
			window.setStyle("div.z-window-embedded-header {font-size: 20em; color: #4476B6; font-weight:bold;}");
			window.setShadow(true);
		} else {
			Sessions.getCurrent().removeAttribute("email");
			Sessions.getCurrent().removeAttribute("target");
			Sessions.getCurrent().removeAttribute("giohang");
			Sessions.getCurrent().invalidate();
			Executions.sendRedirect("index.zul");
		}
	}

	private void showFormProfileNguoiDung() {
		Executions.sendRedirect("customer.zul?target=account_info");

	}

	@Listen("onClick=#dangNhap")
	public void showFormLogin() {
		if (dangNhap.getValue().equals("ĐĂNG NHẬP")) {
			System.out.println("aaaaaaa");
			Window window = (Window) Executions.createComponents(
					"form_login.zul", null, null);
			window.doModal();
			window.setStyle("div.z-window-embedded-header {font-size: 20em; color: #4476B6; font-weight:bold;}");
			window.setShadow(true);
		} else {
			showFormProfileNguoiDung();
		}
	}

}
